// Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
// <https://www.chatopera.com>, Licensed under the Chunsong Public 
// License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
doctype html
html
    head
        meta(charset='utf-8')
        meta(http-equiv='X-UA-Compatible', content='IE=edge')
        meta(http-equiv='Cache-Control', content='no-siteapp')
        meta(name='viewport', content='width=device-width,maximum-scale=1,initial-scale=1,initial-scale=1,user-scalable=no')
        meta(name='apple-mobile-web-app-capable', content='yes')
        title=systemConfig && systemConfig.title && systemConfig.title != '' ? systemConfig.title : '春松客服 | 开源客服系统_联络中心'
        if systemConfig.favlogo
            link(rel="shortcut icon" type="image/x-icon" href='/res/image.html?id=' + systemConfig.favlogo)
        else
            link(rel="shortcut icon" type="image/x-icon" href='/images/favicon.ico')
        link(rel='stylesheet', href='/css/layui.css')
        link(rel='stylesheet', href='/css/login.css')
        script(src='/layui.js')
        script(src='/js/jquery-1.10.2.min.js')
    body.login
        .login-box
            .login-logo
                a
                    if systemConfig && systemConfig.loginlogo && systemConfig.loginlogo != ''
                        img(src='/res/image.html?id=' + systemConfig.loginlogo style="width:220px;")
                    else
                        img(src="images/logo2.png" style="width:220px;")
            //  /.login-logo
            .login-box-body
                p.login-box-msg 注册账号
                form#loginForm.layui-form(action='/addAdmin.html', method='post')
                    .form-group.has-feedback(style='margin-bottom:10px;')
                        span.kfont.form-control-feedback 
                        input#username.form-control.required(name='username', autofocus, required, lay-verify='required', placeholder='用户名')
                    .form-group.has-feedback(style='margin-bottom:10px;')
                        span.layui-icon.form-control-feedback 
                        input#mobile.form-control.required(name='mobile', autofocus, required, lay-verify='required', placeholder='手机')
                    .form-group.has-feedback(style='margin-bottom:10px;')
                        span.kfont.form-control-feedback 
                        input.form-control(type='email', name='email', required, lay-verify='required email', placeholder='邮件地址', autocomplete='off')
                    .form-group.has-feedback(style='margin-bottom:10px;')
                        span.kfont.form-control-feedback 
                        input#password.form-control.required(type='password', name='password', required, lay-verify='required|pass', autocomplete='new-password', placeholder='密码')
                    .row(style='margin-bottom:20px;padding:0 20px;')
                        .col-md-6
                    .row(style='margin-bottom:20px;')
                        //  /.col 
                        .col-xs-12
                            button.btn.btn-block.btn-primary.btn-lg(lay-submit, lay-filter='formDemo') 注册
                        //  /.col 
                        .col-xs-12
                            p.btm-text
                                a(href='/login.html') 已有账号请登录
            //  /.login-box-body 
        script(language='javascript').
            if ((window.frameElement && window.frameElement.id || '') != "") {
                top.location.href = "/register.html";
            }
            layui.use('layer', function () {
                var layer = layui.layer;
                var msg = '#{msg}';
                if (msg == 'username_exist')
                    layer.msg('用户名存在，请重新填写', {icon: 2})
                else if (msg == 'email_exist')
                    layer.msg('邮件存在，请重新填写', {icon: 2})
                else if (msg == 'mobile_exist')
                    layer.msg('手机存在，请重新填写', {icon: 2})
            });
            layui.use('form', function () {
                var form = layui.form();
                form.render(); //更新全部
                form.verify({
                    pass: function (value, item) { //value：表单的值、item：表单的DOM对象
                        if (value && !(/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,18}$/.test(value))) {
                            return '密码由6到18位数字和字母组成';
                        }
                    }
                });
            });
            
